package 集合;

import java.util.HashSet;
import java.util.Set;

public class TestPig {

    public static void main(String[] args) {
        Pig p1 = new Pig();
        p1.setName("佩奇");
        p1.setPrice(8001);
        Pig p2 = new Pig();
        p2.setName("佩奇");
        p2.setPrice(8000);
        //Object equals()+hashCode()
        Set set=new HashSet();
        set.add(p1);
        set.add(p2);
        set.add(p1);
        System.out.println(set.size());//??? 2
        System.out.println(p1);//????  toString()  属于Object
    }
}
